// show and hide sections of a form
function preparePage() {
	document.getElementById("go").onclick = function() {
		if (document.getElementById("search").value=="")
			{ document.getElementById("engineering").style.display = "none";
			alert("Search bar is empty");
			}
		 
		else if (document.getElementById("search").value=="engineering"){
		document.getElementById("engineering").style.display = "block";
		document.getElementById("design").style.display = "none";
		var today=new Date();
		var h=today.getHours();
	    var m=today.getMinutes();
	    var s=today.getSeconds();
		var newListItem = document.createElement("li");
		var tarekh = document.createElement("li");
		newListItem.innerHTML = document.getElementById("search").value;
		tarekh.innerHTML=h+":"+m+":"+s;;
		document.getElementById("savinglist").appendChild(newListItem);
		document.getElementById("savingdate").appendChild(tarekh);
		}

		else if (document.getElementById("search").value=="design"){
		document.getElementById("design").style.display = "block";
		document.getElementById("engineering").style.display = "none";
		var today=new Date();
		var h=today.getHours();
	    var m=today.getMinutes();
	    var s=today.getSeconds();
		var newListItem = document.createElement("li");
		var tarekh = document.createElement("li");
		newListItem.innerHTML = document.getElementById("search").value;
		tarekh.innerHTML=h+":"+m+":"+s;;
		document.getElementById("savinglist").appendChild(newListItem);
		document.getElementById("savingdate").appendChild(tarekh);
		}
		else alert ( "not found");
		}
	};

function selectall() {
	document.getElementById("selectall").onclick = function() {
		if (document.getElementById("selectall").checked)
			{ var array = document.getElementsByName("select");
			for(var i = 0 ; i<array.length; i++)
			{
				array[i].checked=true;
			}
		}

		else{
			var array = document.getElementsByName("select");
			for(var i = 0 ; i<array.length; i++)
			{
				array[i].checked=false;
			}
		}
		}
	};

	

window.onload =  function() {
	preparePage();
	selectall();

};

